﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using WebHelper.Pages;
namespace Web.AppCode
{
    public class Sys_Config : System.Web.UI.Page
    {
       // public  static Model.Sys.AreaData areaObj = new Model.Sys.AreaData();
        public static string GetCurrentCityName()
        {
            return Cookie.GetCookie("cityname");
           // return areaObj.AreaName;
        }
        public static void IntiCity(string citycode)
        {
            //Cookie.Clear("citycode");
            //Cookie.Clear("cityname");
            Model.Sys.AreaData areaObj = Model.Sys.AreaData.GetAreaNameByCode(citycode);
            if (string.IsNullOrEmpty(areaObj.AreaName))
            {
                IntiCity(System.Configuration.ConfigurationManager.AppSettings["defaultCity"].ToString());
                return;
            }
            Cookie.WriteCookie("citycode", areaObj.AreaID.ToString());
            Cookie.WriteCookie("cityname", areaObj.AreaName);
        }
        public static string GetCurrentCityCode()
        {
            
           if(string.IsNullOrEmpty(Cookie.GetCookie("citycode")))
           {
               IntiCity(System.Configuration.ConfigurationManager.AppSettings["defaultCity"].ToString());
           }
           return Cookie.GetCookie("citycode");
         //  return areaObj.AreaID.ToString();
        }
    }
}
